/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Admin
 */
public class testRegex {

    public static void main(String[] args) {

        int url = 0;
        String found = "";
        int money = 0;
        int num = 0;
        int seqn = 0;

        String str = "một con vịt ten ABCXYZ.DEF 10 tuoi nặng 1kg cao 1m2 thật là kinh khủng!?!... the ma ban no duoc 200$ mail cua vit la vit@yahoo.com trang web la www.vit.vn";

        Pattern PUNC1 = Pattern.compile("(\\.+)|([\\p{P}\\+&&[^\\-/\\&]])");
        Pattern URL_NUM_MONY_NAME = Pattern.compile("(\\b((www)|(\\bhttp)|(\\bftp)|(\\bfile))[^ \\),;]*)|([^ ]*.net)([^ ]*.org)|([^ ]*.vn)|([^ ]*.com)|([^ ]+@[^ ]+)|(\\b(\\d[\\d\\.,\\p{Pd} ]*)?\\d[ ]?((AUD)|(SGD)|(USD)|(VNĐ)|(Đ\\b)|(đ\\b)|(đồng\\b)|(\\$)|(S\\$)))|(\\b((AUD)|(SGD)|(USD)|(VNĐ)|(Đ\\b)|(\\$)|(S\\$))[ ]?(\\d[\\d\\.,\\p{Pd} ]*)?\\d)|([\\d]+[,][\\d]+([ ]?\\p{Pd}[ ]?[\\d]+([,]?[\\d]+)?)?)|(\\b((\\(\\d+\\))|(\\d))[\\d\\.\\p{Pd} :/\\)]*\\d)|(\\b(\\p{Lu}\\.)+(\\p{Lu}))");
        Pattern URL = Pattern.compile("(((\\bwww)|(\\bhttp)|(\\bftp)|(\\bfile))[^ \\),;]*)|([^ ]*.net)([^ ]*.org)|([^ ]*.vn)|([^ ]*.com)|([^ ]+@[^ ]+)");
        Pattern MONEY = Pattern.compile("((\\d[\\d\\.,\\p{Pd} ]*)?\\d[ ]?((AUD)|(SGD)|(USD)|(VNĐ)|(Đ\\b)|(đ\\b)|(đồng\\b)|(\\$)|(S\\$)))|(((AUD)|(SGD)|(USD)|(VNĐ)|(Đ\\b)|(\\$)|(S\\$))[ ]?(\\d[\\d\\.,\\p{Pd} ]*)?\\d)");
        Pattern NUM = Pattern.compile("([\\d]+,[\\d]+)|( ((\\(\\d+\\))|(\\d))[\\d\\.\\p{Pd} :/\\)]*\\d)");
        Pattern SEQN = Pattern.compile("((\\p{Lu}\\.)+(\\p{Lu}))");

        Matcher m1 = PUNC1.matcher(str);
        while (m1.find()) {
            found = m1.group();
            System.out.println(m1.pattern());
            System.out.println(found + " m1 done!");

        }
        Matcher mURL = URL.matcher(str);
        while (mURL.find()) {
            found = mURL.group();
            System.out.println(mURL.pattern());
            System.out.println(found);
            System.out.println("mURL done!");

        }

        Matcher mMONEY = MONEY.matcher(str);
        while (mMONEY.find()) {
            found = mMONEY.group();
            System.out.println(mMONEY.pattern());
            System.out.println(found);
            System.out.println("MONEY done!");

        }
        Matcher mNUM = NUM.matcher(str);
        while (mNUM.find()) {
            found = mNUM.group();
            System.out.println(mNUM.pattern());
            System.out.println(found);
            System.out.println("NUM done!");

        }
        Matcher mSEQN = SEQN.matcher(str);
        while (mSEQN.find()) {
            found = mSEQN.group();
            System.out.println(mSEQN.pattern());
            System.out.println(found);
            System.out.println("SEQN done!");

        }

        Matcher m2 = URL_NUM_MONY_NAME.matcher(str);
        while (m2.find()) {
            found = m2.group();
            Matcher mu = URL.matcher(found);
            if (mu.find()) {
                url++; // tìm thấy url
            } else {
                Matcher mm = MONEY.matcher(found);
                if (mm.find()) {
                    money++;//tìm thấy tiền
                } else {
                    Matcher mn = NUM.matcher(found);
                    if (mn.find()) {
                        num++; //tìm thấy số
                    } else {
                        seqn++;// tìm thấy dãy
                    }
                }
            }
        }
        System.out.println("kaka url:"+url+" money:"+money+" num:"+num+" sequn:"+seqn+" ");
    }
}
